import json
import allure
from parameterized import parameterized
import pytest
import requests
from common.logger import Log
from utils.get03_login_data import build_data

@allure.feature('登录模块')
class Test_login():

    def setup_method(self):
        #定义登录接口URL地址
        self.login_url = "http://192.168.3.182:9990/airservice-sso/sso/login"
        self.log=Log("登录接口用例").get_logger()


    @parameterized.expand(build_data)
    @allure.step(title="登录接口的测试用例")
    def test_login_case(self,desc,login_data,message,success):
        response = requests.post(url=self.login_url, json=login_data)

        # with allure.step(title="登录接口描述：{}".format(desc)):
        #     pass

        #添加断言
        assert response.json().get("message") == message
        assert  response.json().get("success") == success

        #打印日志
        self.log.info("{}:{}".format(str(desc[0]),response.json()))




if __name__ == '__main__':
    pytest.main()